/**
 *   For
 *   Created by xs at 2018/1/12
 */
"use strict";
(function () {
    angular.module('app')
        .factory('userService',fn);

    function fn($cookies) {
        var self = {};
        self.profile = {};
        self.user = {};
        self.drugInCart = [];
        self.setUser = function (profile) {
            var username = profile['username'];
            // var userId = profile['userId'];
            var userId = 1;
            var token = profile['token'];
            var userType = profile['userType'];
            console.log(userType);
            var shopId = profile['shopId'];
            self.user['username'] = username;
            self.user['userId'] = userId;
            self.user['token'] = token;
            self.user['userType'] = userType;
            self.user['shopId'] = shopId;
            self.profile = profile;
            $cookies.put('username', username);
            $cookies.put('userId', userId);
            $cookies.put('shopId', shopId);
            $cookies.put('token', token);
        };

        return self;
    }
})();